define(function(require, exports, module) {
    //默认执行
    exports.init = function(){
        //关闭弹框
        $("body").on("click",".close",function(){
            $(".photo-module,.alert-bg").hide(500);
        });
        //nav点击清空缓存
        $("body").delegate(".nav>ul>li",{
            click:function(){
                window.localStorage.name = "";
            }
        });
        //点击返回顶部
        $("body").delegate(".TOP-icon",{
            click:function(){
                exports.pageTop();
            }
        });
        //hover出小弹框事件
        $("body").delegate(".tree-subnav li,.ADDRESS,.contact dd",{
            mouseover:function(){
                $(this).find(".tree-alert").stop().animate({opacity:0.9,display:"block"},500);
            },mouseout:function(){
                $(this).find(".tree-alert").stop().animate({opacity:0,display:"none"},500);
            }
        });
    };
    //本地缓存
    exports.localStorage = function(){
        //点击子级菜单-缓存当前页面
        var Storagelen = window.localStorage.getItem("name"),
            href       = encodeURI(location.href);
        if(href.indexOf("Intelligence")!=-1&&href.indexOf("enter.shtml")!=-1){
            $(".sidebar-nav>li").eq(4).addClass("selected").siblings("li").removeClass("selected");
            $(".content>.box").eq(4).show().siblings(".box").hide();
        }else if(Storagelen){
            $(".sidebar-nav>li").eq(Storagelen).addClass("selected").siblings("li").removeClass("selected");
            $(".content>.box").eq(Storagelen).show().siblings(".box").hide();
        };
        //nav点击清空缓存
        $("body").delegate(".nav>ul>li",{
            click:function(){
                window.localStorage.name = "";
            }
        });
        //点击侧栏菜单
        $("#main").delegate(".sidebar-nav li",{
            click:function(){
                var $box = $(this).attr("Kclass");
                if($box){
                    $(".shape-white").removeClass("shape-white");
                    $(this).addClass("selected").find("i").addClass("shape-white").end().siblings().removeClass("selected");
                    $("."+$box).show(500).siblings("div").hide();
                    window.localStorage.name = $(this).index();
                };
            }
        });//首页点击优秀员工养成记-
        $(".js-excellent").on("click",function(){
            window.localStorage.name = 3;
        });
        //点击sidebar菜单记缓存
        $("body").delegate(".sub-nav>li",{
            click:function(event){
                window.localStorage.name = $(this).index();
                event.stopPropagation();
            }
        });
    };
    //content最小高度获取
    exports.minheight = function(){
        var $H       = $(document).height(),
            $header  = $("#header").height()+1,
            $nav     = $(".nav").height()+1,
            $footer  = $('#footer').height();
        //$(".content").css({minHeight:$H-$header-$nav-$contact-$footer-250-150});
        console.log($H,$header,$nav,$footer);
        $("#main").css({minHeight:$H-$header-$nav-$footer-231});
    };
    //进入页面的顶部动画效果
    exports.Animate = function(){
        var $w      = $(window).width(),
            $header = $("#header").height();
        $("#LOGO").css({opacity:0,left:-330});
        if(!$("body").hasClass("Home")){
            $("body,html").scrollTop($header);
        }
        $("#LOGO").animate({opacity:1,left:0},2000,function(){
            if($("body").scrollTop()>$header||document.documentElement.scrollTop>$header){
                return;
            };
            $("body,html").animate({scrollTop:$header},2000);
        });
    };
    //返回顶部
    exports.pageTop = function(){
        $("body,html").animate({scrollTop:0},1000).animate({scrollTop:$("#header").height()},1000);
    };
    //定位屏幕移动事件触发
    exports.screenMove = function(){
        if(document.all){
            //ie浏览器
            document.documentElement.onscroll = function(){
                navonscroll();
            };
        }else{
            //其它浏览器
            document.onscroll = function(){
                navonscroll();
            };
        };
        function navonscroll(){
            var $val,
                $topval    = ($("#header").height()+$(".nav").height())+82,     //头部的高度加,容器距离#main 头部的距离
                $bottomval = ($(".contact").height()+$(".TOP").height()+$('#footer').height()+$(".sidebar-nav").height())+75, //底部的高度加,容器距离#main 底部的距离
                $Dh        = $(document).height();
            $("body").scrollTop() > 0 ? $val = $("body").scrollTop() : $val = $("html").scrollTop();
            $Dh - $val < $bottomval ? $val = -($bottomval - ($Dh - $val)) : $val = $val ;
            if($val > $topval){
                $(".sidebar ul").css({position:"fixed",top:0,width:185});
            }else if($val<0){
                $(".sidebar ul").css({position:"fixed",top:$val,width:185});
            }else{
                $(".sidebar ul").css({position:"static"});
            };
        };
    };
    //页面信息切换
    exports.pageDChange = function(){
        //左切换
        $("body").delegate(".changing-over-left",{
            click:function(){
                var $box  = $(this).closest(".changing-js-box"),
                    index = $(this).parent().prev(".changing-over").attr("num");
                !index?index=$box.find(".changing-over").last().attr("num"):index=index;
                $box.find(".changing-over").eq(index).show(500).siblings(".changing-over").hide();
            }
        });
        //右切换
        $("body").delegate(".changing-over-right",{
            click:function(){
                var $box  = $(this).closest(".changing-js-box"),
                    index = $(this).parent().next(".changing-over").attr("num");
                !index?index=0:index=index;
                $box.find(".changing-over").eq(index).show(500).siblings(".changing-over").hide();
            }
        });
    };
    //默认执行
    exports.init();
});